package com.rede.didiok.sms.event.service.impl;

import java.util.List;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import com.rede.didiok.common.dto.user.MessagePushDto;
import com.rede.didiok.common.dto.user.UserDto;
import com.rede.didiok.common.enums.PushMethodEnum;
import com.rede.didiok.sms.event.annotation.MessagePushType;
import com.rede.didiok.sms.event.service.AbstractMessagePushHandler;

/**
 * 站内信推送事件处理器
 */
@Slf4j
@Component
@MessagePushType({PushMethodEnum.NOTICE})
public class NoticePushHandler extends AbstractMessagePushHandler {

    @Override
    public void pushHandler(MessagePushDto messagePush, List<UserDto> userList) {
        // 站内信推送
        log.error("开始推送站内信触达，标题：{}", messagePush.getTitle());
        // 开始批量发送站内信
        for (UserDto user : userList) {
            asyncService.executeAsyncBusinessNotice(user.getUid(), messagePush.getContent());
        }
        log.error("站内信触达推送完成");
    }
}
